package com.example.springboot.service;

import com.example.springboot.entity.ForumPostLike;
import com.example.springboot.mapper.ForumPostLikeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ForumPostLikeService {

    @Autowired
    private ForumPostLikeMapper forumPostLikeMapper;

    public void likePost(ForumPostLike like) {
        forumPostLikeMapper.insertLike(like);
    }

    public void unlikePost(Integer postId, Integer userId) {
        forumPostLikeMapper.deleteLike(postId, userId);
    }

    public boolean isPostLikedByUser(Integer postId, Integer userId) {
        return forumPostLikeMapper.selectLike(postId, userId) != null;
    }
    public List<ForumPostLike> getLikesByUserId(Integer userId) {
        return forumPostLikeMapper.findByUserId(userId);
    }
}